<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" onkeyup="to_upper(this)">
    
    <script>
        //1. 键盘按下去
        // document.onkeydown=function(event){
        //     let e = event || window.event;
        //     //获取键盘码  a-65  enter-13
        //     alert(e.keyCode);
        // }

        function to_upper(obj){
            obj.value = obj.value.toUpperCase();
        }

        
    </script>

</body>
</html>